package com.csdn;

public class Test6 {
    public static void main(String[] args) {
        Person person = new Person("李白",19);
        System.out.println(person);
        System.out.println(person.toString());
    }
}

class Person {
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof Person)) {
            return false;
        }
        return ((Person) obj).age == age && ((Person) obj).name.equals(name);
    }

}

